<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>v-bind动态绑定class(对象语法)</title>
    <style>
      .active {
        color: red;
      }
      .line {
        background-color: seagreen;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <h1 class="active">{{message}}</h1>
      <h1 :class="active">{{message}}</h1>

      <!-- <h1 v-bind:class="{key1:value1,key:value2}">{{message}}</h1> -->
      <h1 v-bind:class="{active:isActive,line:isLine}">{{message}}</h1>
      <h1 v-bind:class="getClasses()">{{message}}</h1>
      <button @click="btnclick">点击</button>
    </div>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
      var app = new Vue({
        el: "#app",
        data: {
          message: "你好呀",
          isActive: true,
          isLine: true,
        },
        methods: {
          btnclick: function () {
            this.isActive = !this.isActive;
          },
          getClasses: function () {
            return { active: this.isActive, line: this.isLine };
          },
        },
      });
    </script>
  </body>
</html>
